{% extends "base.html" %}

{% block title %}班级管理{% endblock %}
{% block page_title %}班级管理系统{% endblock %}

{% block content %}
<!-- 添加班级表单 -->
<div class="card mb-4">
    <div class="card-header d-flex justify-content-between align-items-center">
        <span><i class="fas fa-plus-circle me-2"></i>添加新班级</span>
    </div>
    <div class="card-body">
        <form method="post" class="row g-3 align-items-center">
            {% csrf_token %}
            <div class="col-md-8">
                <input type="text" name="new_id" placeholder="输入新班级编号" required 
                       class="form-control form-control-lg">
            </div>
            <div class="col-md-4">
                <button type="submit" name="add_banji" class="btn btn-primary w-100">
                    <i class="fas fa-plus me-1"></i>添加班级
                </button>
            </div>
        </form>
    </div>
</div>

<!-- 班级列表 -->
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <span><i class="fas fa-list me-2"></i>班级列表</span>
        <span class="badge bg-primary rounded-pill">{{ banji_list|length }}</span>
    </div>
    <div class="card-body">
        {% if banji_list %}
        <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
            {% for banji in banji_list %}
            <div class="col">
                <div class="card h-100">
                    <div class="card-body">
                        <h5 class="card-title">{{ banji }}班</h5>
                        <p class="card-text text-muted">班级编号: {{ banji }}</p>
                    </div>
                    <div class="card-footer bg-white d-flex justify-content-between">
                        <a href="{% url 'manage_students' banji %}" 
                           class="btn btn-sm btn-outline-primary">
                            <i class="fas fa-user-edit me-1"></i>管理学生
                        </a>
                        <form method="post" class="d-inline">
                            {% csrf_token %}
                            <input type="hidden" name="delete_banji" value="{{ banji }}">
                            <button type="submit" class="btn btn-sm btn-outline-danger">
                                <i class="fas fa-trash-alt me-1"></i>删除
                            </button>
                        </form>
                    </div>
                </div>
            </div>
            {% endfor %}
        </div>
        {% else %}
        <div class="text-center py-5">
            <i class="fas fa-folder-open fa-3x text-muted mb-3"></i>
            <h5>暂无班级数据</h5>
            <p class="text-muted">请添加新班级以开始管理</p>
        </div>
        {% endif %}
    </div>
</div>
{% endblock %}